<template>
  <div>
    <el-table
      :data="devlist"
      :show-header="true"
      style="width: 100%"
      :height="235"
      class="ddt"
      :cell-style="{ textAlign: 'center', padding: '0', border: 'none' }"
      :header-cell-style="{
        'text-align': 'center',
        'background-color': '#fff !important',
        border: 'none',
        padding: '0',
        'font-size': '11px',
        color: '#000',
      }"
    >
      <el-table-column label="设备列表" width="220">
        <template slot-scope="scope">
          <el-popover placement="top" trigger="hover">
            <div class="ddt-tpis">
              <span class="ddt-tpis-colorbox zy"></span>
              <span class="name">作业：</span>
              <span class="value">{{ scope.row.zy }}</span>
            </div>
            <div class="ddt-tpis">
              <span class="ddt-tpis-colorbox gz"></span>
              <span class="name">故障：</span>
              <span class="value">{{ scope.row.gz }}</span>
            </div>
            <div class="ddt-tpis">
              <span class="ddt-tpis-colorbox kx"></span>
              <span class="name">空闲：</span>
              <span class="value">{{ scope.row.kx }}</span>
            </div>
            <div slot="reference" class="ddt-b">
              <div class="ddt-box-name">RS-1</div>
              <div class="ddt-box">
                <div
                  class="ddt-box-color"
                  :style="`width:${Percentage(
                    Number(scope.row.zy),
                    scope.row
                  )}%`"
                ></div>
                <div
                  class="ddt-box-color1"
                  :style="`width:${Percentage(
                    Number(scope.row.gz),
                    scope.row
                  )}%;left:${Percentage(Number(scope.row.zy), scope.row)}%`"
                ></div>
              </div>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column prop="zytons">
        <template slot="header">
          <div class="name">作业量</div>
          <div class="unit">万吨</div>
        </template>
      </el-table-column>
      <el-table-column prop="zytons">
        <template slot="header">
          <div class="name">用电量</div>
          <div class="unit">千瓦时</div>
        </template>
      </el-table-column>
      <el-table-column prop="zytons">
        <template slot="header">
          <div class="name">完好率</div>
          <div class="unit">%</div>
        </template>
      </el-table-column>
    </el-table>
    <div class="ddt-bar ddt-tpis">
      <div class="ddt-bar-box">
        <span class="ddt-tpis-colorbox zy"></span>
        <span class="name">作业</span>
      </div>
      <div class="ddt-bar-box">
        <span class="ddt-tpis-colorbox gz"></span>
        <span class="name">故障</span>
      </div>
      <div class="ddt-bar-box">
        <span class="ddt-tpis-colorbox kx"></span>
        <span class="name">空闲</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Ddt",
  data() {
    return {
      devlist: [{ zy: 1000, gz: 1000, kx: 1111, zytons: 1212 }],
    };
  },
};
</script>

<style lang="scss">
$zy: #76e1ff;
$kx: #ffecb2;
$gz: #fd8890;
.gz {
  background-color: $gz;
}
.kx {
  background-color: $kx;
}
.zy {
  background-color: $zy;
}
.ddt-b {
  display: flex;
  .ddt-box-name {
    margin-right: 3px;
  }
}
.ddt-bar {
  display: flex;
  justify-content: center;
  &-box {
    margin-left: 20px;
  }
}
.ddt-tpis {
  &-colorbox {
    display: inline-block;
    width: 20px;
    height: 10px;
    border-radius: 5px;
  }
  .name {
    margin-left: 10px;
  }
}
.ddt {
  .ddt-box {
    position: relative;
    @extend .kx;
    height: 10px;
    line-height: 23px;
    border-radius: 5px;
    width: 75%;
    margin: auto;
    overflow: hidden;
    &-color {
      position: absolute;
      left: 0;
      top: 0;
      height: 100%;
      @extend .zy;
    }
    &-color1 {
      position: absolute;
      top: 0;
      height: 100%;
      @extend .gz;
    }
  }
}
</style>
